export default {
    namespaced: true,
    state: () => ({
      count: 0
    }),
    mutations: {
      INCREMENT(state) {
        state.count++
      },
      SET_COUNT(state, value) {
        state.count = value
      }
    },
    actions: {
      increment({ commit }) {
        commit('INCREMENT')
      },
      async fetchInitialCount({ commit }) {
        // 模拟API请求
        const response = await new Promise(resolve => 
          setTimeout(() => resolve(5), 500)
        )
        commit('SET_COUNT', response)
      }
    },
    getters: {
      doubleCount: state => state.count * 2
    }
  }